<%@ page language="java" contentType="text/html; charset=utf-8"  pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> 

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="keywords" content="jQuery,easyform,form validation,javascript,js,jq,jquery,表单验证,插件">
    <meta name="description" content="jQuery.Easyform表单验证插件">

    <title>注册页</title>

    <meta name="description" content="">
    <meta http-equiv="cleartype" content="on">

    <link rel="stylesheet" href="res/zhuce/css/platform-1.css">
    <link rel="stylesheet" href="res/zhuce/js/easyform/easyform.css">

    <link rel="stylesheet" href="res/zhuce/css/tab.css">

    <script src="res/zhuce/js/jquery-2.1.0.min.js"></script>
    <script src="res/zhuce/js/easyform/easyform.js"></script>
    <link rel="stylesheet" href="res/zhuce/js/easyform/easyform.css">
<script src="res/zhuce/js/jquery-2.1.0.min.js"></script>
<script src="res/zhuce/js/easyform/easyform.js"></script>



</head>
<body>

<div class="page">

    <div class="header">

        <a class="link title-ani"  data-letters="注册">注册</a>
        <br>

      

    </div>

    <div class="form-div">
        <form id="reg-form" action="" method="post">

            <table>
                <tr>
                    <td>用户名</td>
                    <td><input name="uid" type="text" id="yonghuming1"
                               data-easyform="length:4 16;char-normal;real-time;ajax:ajax_demo(1);"
                               data-message="用户名必须为4—16位的英文字母或数字"
                               data-easytip="position:top;class:easy-blue;" data-message-ajax="用户名已存在!">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input name="psw1" type="password" id="mima1" data-easyform="length:6 16;"
                               data-message="密码必须为6—16位"
                               data-easytip="class:easy-blue;"></td>
                </tr>
                <tr>
                    <td>确认密码</td>
                    <td><input name="psw2" type="password" id="mima2" data-easyform="length:6 16;equal:#psw1;"
                               data-message="两次密码输入要一致" data-easytip="class:easy-blue;"></td>
                </tr>
               <!--  <tr>
                    <td>email</td>
                    <td><input name="email" type="text" id="email" data-easyform="email;real-time;easytip:false;"
                               data-message="Email格式要正确"
                               data-easytip="class:easy-blue;"></td>
                </tr> -->
                <tr>
                    <td>姓名</td>
                    <td><input name="nickname" type="text" id="xingming" data-easyform="length:2 16;"
                               data-easytip="class:easy-blue;position:bottom;"></td>
                </tr>
            </table>

            <div class="buttons" style="margin-top: 50px;">
                <input value="注 册" type="submit" style="margin-right:20px; margin-top:20px;" onclick=" zhuce();return false;">
                <!-- <input value="我有账号，我要登录" type="button" style="margin-right:45px; margin-top:20px;"> -->
                <a href="denglu?" type="button" style="margin-right:20px; margin-top:20px;">我有账号，我要登录</a>
            </div>

            <br class="clear">
        </form>
    </div>

    <!--简介-->
    

    <!--easyform-->

    <!--例子-->
   
<!--注册-->
<script type="text/javascript">
     function zhuce () {

     
            // body...
            var yonghuming=document.getElementById("yonghuming1").value;
            var mima=document.getElementById("mima1").value;
            var mima2=document.getElementById("mima2").value;
            var xingming = document.getElementById("xingming").value;

            // alert(yonghuming);
                if (mima!=mima2) {
                    alert("密码输入不一致");
                    return false;
                };
                if (yonghuming == "" || mima=="" || xingming == "") {
                    alert("不能为空！");
                    return false;
                };
            $.ajax( {  
     url:'/zhuce',// 跳转到 action url:表示后面跟访问地址 
     data:{  
                yonghuming:document.getElementById("yonghuming1").value,
                mima:document.getElementById("mima1").value,
                xingming:document.getElementById("xingming").value
                //data:后面跟参数
      },  
     type:'post',  
     cache:false,  
     async:false,
    success:function(data) {  
        // var s = "登陆成功";
        // 当请求成功之后，返回的数据就在这做处理，我现在只是做了一个简单的弹出。
        // response.setCharacterEncoding("UTF-8");
        var obj = JSON.parse(data);

        alert(obj.f);
     
     		if (obj.f == "注册成功") {
     			window.location.href="http://localhost:8081/daikuan/denglu?"; 
     		}
         // window.location.href="http://localhost:8081/daikuan/denglu?";   
      },  
     error : function() {  
          // view("异常！");  请求失败的时候，在这里做处理
           alert("错误");  
      }  
 });
        }        
</script>

</body>
</html>
